package com.ChengXiZi.mapper;

import com.ChengXiZi.dto.UserAddDTO;
import com.ChengXiZi.dto.UserPageDTO;
import com.ChengXiZi.entity.User;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {

    /**
     * 根据用户名查询数据
     * @param username
     * @return
     */
    @Select("select * from user where username = #{username}")
    User getByUsername(String username);

    /**
     * 新增用户
     * @param user
     */
    void insert(User user);

    /**
     * 分页查询用户
     * @param userPageDTO
     * @return
     */
    Page<User> pageQuery(UserPageDTO userPageDTO);

    /**
     * 动态更新用户
     * @param user
     */
    void update(User user);

    /**
     * 根据id查询数据
     * @param userId
     * @return
     */
    @Select("select * from user where id = #{userId}")
    User getById(Long userId);
}
